package com.huyn.baseframework.model;

import java.io.Serializable;
import java.util.HashMap;

/**
 * Created by huyaonan on 16/8/31.
 */
public class VideoPlayModel implements Serializable {

    public String videoId;
    public String videoNo;
    public VideoWithDefinitionModel videoModel;

    public boolean isUrlPlayValid() {
        if(videoModel != null && videoModel.getDefaultDefinition() != null)
            return true;
        return false;
    }

    public HashMap<Integer, String> getDefinitions() {
        if(videoModel != null) {
            return videoModel.getDefinitions();
        }
        return new HashMap<>();
    }

    public int getDefaultDefinition() {
        if(videoModel != null)
            return videoModel.defaultdefinition;
        return 0;
    }

    public String getPlayUrl() {
        if(videoModel != null) {
            VideoDefinition video = videoModel.getDefaultDefinition();
            if(video != null)
                return video.playurl;
        }
        return null;
    }

    public String getPlayUrl(int definition) {
        if(videoModel != null) {
            VideoDefinition video = videoModel.getByDefinition(definition);
            if(video != null)
                return video.playurl;
        }
        return null;
    }

}
